﻿using Microsoft.EntityFrameworkCore;
using Production.DomainLib.AggregatesModel.ProductionResourceAggregate;
using Swimj.DomainLib.SeedWork;

namespace Production.InfrastructureLib.Repositories
{
    public class ProductionResourceRepository : IProductionResourceRepository
    {
        private readonly ProductionDbContext _dbContext;
        public IUnitOfWork UnitOfWork => _dbContext;

        public ProductionResourceRepository(ProductionDbContext dbContext)
        {
            _dbContext = dbContext;
        }


        public ProductionResource Add(ProductionResource productionResource)
        {
            return _dbContext.ProductionResources.Add(productionResource).Entity;
        }

        public Task<ProductionResource?> Get(int requestId)
        {
            return _dbContext.ProductionResources.FirstOrDefaultAsync(i => i.Id == requestId);
        }
    }
}